import fetch from '@/utils/fetch'

// 备机申请
export function apiApply (applyDto) {
  return fetch({
    url: '/api/v1/spare',
    method: 'POST',
    data: applyDto
  })
}

// 备机审核一览
// export function apiGetCheckList(userId,listQuery) {
//   var data = listQuery;
//   data.push({userId: userId});
//   return fetch({
//     url: '/api/v1/spare/audit',
//     method: 'GET',
//     params: data
//   })
// }
export function apiGetCheckList (listQuery) {
  return fetch({
    url: '/api/v1/spare/auditList',
    method: 'GET',
    params: listQuery
  })
}

// 备机审核
export function apiCheck (checkDto) {
  return fetch({
    url: '/api/v1/spare/audit',
    method: 'POST',
    data: checkDto
  })
}

// 备机发放一览
export function apiGetGrantList (listQuery) {
  return fetch({
    url: '/api/v1/spare/distributeList',
    method: 'GET',
    params: listQuery
  })
}
// 备机已审核一览
export function apiGetAlreadyCheckList (listQuery) {
  return fetch({
    url: '/api/v1/spare/alreadyList',
    method: 'GET',
    params: listQuery
  })
}

// 根据型号获取物品名称
export function apiGetItem (id) {
  return fetch({
    url: '/api/v1/spare/item',
    method: 'GET',
    params: {
      modelId: id
    }
  })
}

// 发放
export function apiSpareDistribute (spareDistributeDto) {
  return fetch({
    url: '/api/v1/distribute',
    method: 'POST',
    data: spareDistributeDto
  })
}

// 备机收机
export function apiGetSpareReceiveList (listQuery) {
  return fetch({
    url: 'api/v1/spare/receiveList',
    method: 'GET',
    params: listQuery
  })
}

export function apiSpareReceive (spareDto) {
  return fetch({
    url: '/api/v1/stock/good/spare/receive',
    method: 'POST',
    data: spareDto
  })
}

// 个人备机申请记录查询
export function apiSpareSelfList (listQuery) {
  return fetch({
    url: 'api/v1/spare/self/list',
    method: 'GET',
    params: listQuery
  })
}

// 个人备机申请详情查询
export function apiSpareSelfDetail (id) {
  return fetch({
    url: 'api/v1/spare/self/detail',
    method: 'GET',
    params: {
      applyId: id
    }
  })
}
